const { encryptByPublicKey } = require("./src/utils/encrypt_util")

const testLogin = function () {
    let obj = {}
    obj.sessionId = 'e10adc3949ba59abbe56e057f20f883e'
    const data = JSON.stringify(obj)

    fetch("http://127.0.0.1:3000/login",
        {
            method: 'POST',
            body: data,
            headers: {
                'Content-type': 'application/json; charset=UTF-8',

            },
        }).then((res) => res.json())
        .then((json) => console.log(json))
        .catch((e) => console.error(e))

}

const testOther = async function () {
    let obj = {}
    obj.account = "aabbccdd"

    const sessionId = 'e10adc3949ba59abbe56e057f20f883e'
    const publicKey = 'TUlJQkNnS0NBUUVBdGpZZ0x6R2gxZjBpelNkeDVIUTBrTzFCWFlaNGU0VTNxSUJDV2FUQWF3U2pBOEVnSWJpWQpXYkxjWncvY00wRzdRaHY5ZTM5N09mMDk3eXp1dVdXRy9Vcm5GMENLejVScmVrdng2azc2REYyNGd3UkV3VUZaClkvd3pTSEZMQlVrZHo0cVdqZUVvY2lJZ0FkTi9KMXN5QXJBVXRBTjFrM1QraUY1YURJOVhQQlpFWDVNd3FWdkwKT3J4aEtMVjdua1EvMUF2RzZqU1hmKyszS2pHdkM2TW00c2JUVWs5WkpHUEFQbFlpVy95amJZUkdlRFhMTE5yaQorTjZzL2ozbUlVdE5VZWJ3bzZnVHlzTWZ5bUdrNjJHMUJNYS9kK202WU4zUDhyQjMxYnVKajM2cm1adW1sUzA4ClIvaWRlbGxCV2hEdDMza1pvWFV0Z0xnVEI2UlZtcHFhbHdJREFRQUI='

    const encData = encryptByPublicKey(publicKey, JSON.stringify(obj))

    fetch("http://127.0.0.1:3000/test",
        {
            method: 'POST',
            body: JSON.stringify({ data: encData }),
            headers: {
                'Content-type': 'application/json; charset=UTF-8',
                'sessionid': sessionId
            },
        }).then((res)=>{
            
            console.log(res.status)
            return res.json()
        })
        .then((json) => console.log(json))
        .catch((e) => console.error(e))

}

testOther()